<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/11/1
 * Time: 16:54
 */

if (!defined('IN_DISCUZ')) {
    exit('Access Denied');
}


$postData = [
    'channelName'=>$_POST['channelName'],
    'start'=>$_POST['start'],
    'end'=>$_POST['end'],
    'outputRate'=>json_encode($_POST['outputRate']),
    'logo'=>$_FILES['image1']['name'],
    'channelDescribe' => $_POST['channelDescribe']
];
$where = [
  'id' =>  $_POST['active_id']
];



//删除远程API
$url = 'http://test.olbike.com:81/php/bikeshop/V2/?service=Live.Edit';

$data = [
    'channelId'=> $_POST['channelId'],
    'channelName' =>$_POST['channelName'],
    'channelDescribe' => $_POST['channelDescribe']
];


$ch = curl_init();  //开启curl
curl_setopt($ch, CURLOPT_URL, $url);  //curl请求地址
curl_setopt($ch, CURLOPT_POST, 1);   //请求一个正规的HTTP POST请求, 第三个参数要非零
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);   //默认0是直接将信息显示在浏览器中,设为1表示就能取值
curl_setopt($ch, CURLOPT_HEADER,0);  //如果成功,请求头信息不显示, 1就显示
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);  //使用POST方法请求

$buf = curl_exec($ch);    //抓取URL并把它传递给浏览器
DB::update('zhibo',$postData,$where);


//print_r($_POST);

if($buf['data']['code'] == 0){
    echo '<script>alert("编辑成功");history.go(-1);location.reload()</script>';
}else{
    echo '<script>alert("编辑失败");history.go(-1);location.reload()</script>';
}


